<?php

/*
class Layout, container for defining component layout on a page
Copyright (C) 2011  Petr Čermák

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

require_once 'Checker.php';
require_once 'Container.php';

class Layout extends Container{

    /**This function is called before the components are rendered.*/
    protected function beforeRender(){}

    /**Processes the request from user and renders all added components.*/
    public function processRequest(){

        //parent::processActions();
        $this->processHelpers();

        $this->beforeRender();

        $view = $this->getView();
        Checker::checkNull($view);
        /*foreach($this->getComponents() as $name => $component){
            if($component->isEnabled()){
                $component->initialize();
                if($component instanceof Router)
                    $component->updateCurrentComponent();
            }
        }*/
        foreach($this->getComponents() as $name => $component)
            if($component->isEnabled())
                $view->setValue($name, $component->createOutput());
            else $view->setValue($name, "");

        $this->processAndView();
        //parent::processRequest();
        //$view->render();
    }

}
?>
